import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '工艺编码',
    align: "center",
    dataIndex: 'number'
  },
  {
    title: '生产工艺名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '反应类型',
    align: "center",
    dataIndex: 'reactionType'
  },
  {
    title: '重点监控装置',
    align: "center",
    dataIndex: 'riskDeviceId_dictText'
  },
  {
    title: '重点监控单元',
    align: "center",
    dataIndex: 'riskUnitId_dictText'
  },
  {
    title: '最终产品',
    align: "center",
    dataIndex: 'finalProduct'
  },
  {
    title: '最终产品物质形态',
    align: "center",
    dataIndex: 'finalProductMediumForm'
  },
  {
    title: '中间产品',
    align: "center",
    dataIndex: 'intermediateProduct'
  },
  {
    title: '中间产品物质形态',
    align: "center",
    dataIndex: 'intermediateProductForm_dictText'
  },
  {
    title: '工艺危险特点',
    align: "center",
    dataIndex: 'processHazardCharacteristics'
  },
  {
    title: '工艺所在地址',
    align: "center",
    dataIndex: 'processLocation'
  },
  {
    title: '工艺控制参数',
    align: "center",
    dataIndex: 'processControlParameter'
  },
  {
    title: '工艺控制方式',
    align: "center",
    dataIndex: 'processControlMode'
  },
  {
    title: '投用日期',
    align: "center",
    dataIndex: 'sserviceTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '重点监控工艺参数',
    align: "center",
    dataIndex: 'processParameter'
  },
  {
    title: '操作温度',
    align: "center",
    dataIndex: 'operatingTemperature'
  },
  {
    title: '操作压力',
    align: "center",
    dataIndex: 'operatingPressure'
  },
  {
    title: '是否重点监管化工工艺',
    align: "center",
    dataIndex: 'isKeySupervision_dictText'
  },
  {
    title: '岗位操作人数',
    align: "center",
    dataIndex: 'operatorsNumber'
  },
  {
    title: '持证人数',
    align: "center",
    dataIndex: 'cardholdersNumber'
  },
  {
    title: '设计单位',
    align: "center",
    dataIndex: 'designCompany'
  },
  {
    title: '设计单位资质等级',
    align: "center",
    dataIndex: 'designCompanyAptitudeLevel'
  },
  {
    title: '工艺系统简况',
    align: "center",
    dataIndex: 'processSystemBrief'
  },
  {
    title: '自动控制措施',
    align: "center",
    dataIndex: 'automaticControlMeasure'
  },
  {
    title: '资质等级描述',
    align: "center",
    dataIndex: 'qualificationLevelDescription'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '上传文件',
    align: "center",
    dataIndex: 'doc',
  },
  {
    title: '上传图片',
    align: "center",
    dataIndex: 'img',
    customRender: render.renderImage,
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "工艺编码",
    field: 'number',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "生产工艺名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "反应类型",
    field: 'reactionType',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "重点监控装置",
    field: 'riskDeviceId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_risk_device,name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "重点监控单元",
    field: 'riskUnitId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_risk_unit,risk_unit_name,id"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '工艺编码',
    field: 'number',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入工艺编码!'},
             ];
    },
  },
  {
    label: '生产工艺名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入生产工艺名称!'},
             ];
    },
  },
  {
    label: '反应类型',
    field: 'reactionType',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入反应类型!'},
             ];
    },
  },
  {
    label: '重点监控装置',
    field: 'riskDeviceId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_risk_device,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入重点监控装置!'},
             ];
    },
  },
  {
    label: '重点监控单元',
    field: 'riskUnitId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tb_base_risk_unit,risk_unit_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入重点监控单元!'},
             ];
    },
  },
  {
    label: '最终产品',
    field: 'finalProduct',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入最终产品!'},
             ];
    },
  },
  {
    label: '最终产品物质形态',
    field: 'finalProductMediumForm',
    component: 'Input',
  },
  {
    label: '中间产品',
    field: 'intermediateProduct',
    component: 'Input',
  },
  {
    label: '中间产品物质形态',
    field: 'intermediateProductForm',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "mediumForm"
    },
  },
  {
    label: '工艺危险特点',
    field: 'processHazardCharacteristics',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入工艺危险特点!'},
             ];
    },
  },
  {
    label: '工艺所在地址',
    field: 'processLocation',
    component: 'Input',
  },
  {
    label: '工艺控制参数',
    field: 'processControlParameter',
    component: 'Input',
  },
  {
    label: '工艺控制方式',
    field: 'processControlMode',
    component: 'Input',
  },
  {
    label: '投用日期',
    field: 'sserviceTime',
    component: 'DatePicker',
  },
  {
    label: '重点监控工艺参数',
    field: 'processParameter',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入重点监控工艺参数!'},
             ];
    },
  },
  {
    label: '操作温度',
    field: 'operatingTemperature',
    component: 'Input',
  },
  {
    label: '操作压力',
    field: 'operatingPressure',
    component: 'Input',
  },
  {
    label: '是否重点监管化工工艺',
    field: 'isKeySupervision',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否重点监管化工工艺!'},
             ];
    },
  },
  {
    label: '岗位操作人数',
    field: 'operatorsNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入岗位操作人数!'},
             ];
    },
  },
  {
    label: '持证人数',
    field: 'cardholdersNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入持证人数!'},
             ];
    },
  },
  {
    label: '设计单位',
    field: 'designCompany',
    component: 'Input',
  },
  {
    label: '设计单位资质等级',
    field: 'designCompanyAptitudeLevel',
    component: 'Input',
  },
  {
    label: '工艺系统简况',
    field: 'processSystemBrief',
    component: 'InputTextArea',
  },
  {
    label: '自动控制措施',
    field: 'automaticControlMeasure',
    component: 'InputTextArea',
  },
  {
    label: '资质等级描述',
    field: 'qualificationLevelDescription',
    component: 'InputTextArea',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "normalOrStop"
    },
  },
  {
    label: '上传文件',
    field: 'doc',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '上传图片',
    field: 'img',
    component: 'JImageUpload',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  number: {title: '工艺编码',order: 0,view: 'text', type: 'string',},
  name: {title: '生产工艺名称',order: 1,view: 'text', type: 'string',},
  reactionType: {title: '反应类型',order: 2,view: 'text', type: 'string',},
  riskDeviceId: {title: '重点监控装置',order: 3,view: 'list', type: 'string',dictTable: "tb_base_risk_device", dictCode: 'id', dictText: 'name',},
  riskUnitId: {title: '重点监控单元',order: 4,view: 'list', type: 'string',dictTable: "tb_base_risk_unit", dictCode: 'id', dictText: 'risk_unit_name',},
  finalProduct: {title: '最终产品',order: 5,view: 'text', type: 'string',},
  finalProductMediumForm: {title: '最终产品物质形态',order: 6,view: 'text', type: 'string',},
  intermediateProduct: {title: '中间产品',order: 7,view: 'text', type: 'string',},
  intermediateProductForm: {title: '中间产品物质形态',order: 8,view: 'list', type: 'string',dictCode: 'mediumForm',},
  processHazardCharacteristics: {title: '工艺危险特点',order: 9,view: 'text', type: 'string',},
  processLocation: {title: '工艺所在地址',order: 10,view: 'text', type: 'string',},
  processControlParameter: {title: '工艺控制参数',order: 11,view: 'text', type: 'string',},
  processControlMode: {title: '工艺控制方式',order: 12,view: 'text', type: 'string',},
  sserviceTime: {title: '投用日期',order: 13,view: 'date', type: 'string',},
  processParameter: {title: '重点监控工艺参数',order: 14,view: 'text', type: 'string',},
  operatingTemperature: {title: '操作温度',order: 15,view: 'text', type: 'string',},
  operatingPressure: {title: '操作压力',order: 16,view: 'text', type: 'string',},
  isKeySupervision: {title: '是否重点监管化工工艺',order: 17,view: 'radio', type: 'string',},
  operatorsNumber: {title: '岗位操作人数',order: 18,view: 'text', type: 'string',},
  cardholdersNumber: {title: '持证人数',order: 19,view: 'text', type: 'string',},
  designCompany: {title: '设计单位',order: 20,view: 'text', type: 'string',},
  designCompanyAptitudeLevel: {title: '设计单位资质等级',order: 21,view: 'text', type: 'string',},
  processSystemBrief: {title: '工艺系统简况',order: 22,view: 'textarea', type: 'string',},
  automaticControlMeasure: {title: '自动控制措施',order: 23,view: 'textarea', type: 'string',},
  qualificationLevelDescription: {title: '资质等级描述',order: 24,view: 'textarea', type: 'string',},
  status: {title: '状态',order: 25,view: 'radio', type: 'string',},
  doc: {title: '上传文件',order: 26,view: 'file', type: 'string',},
  img: {title: '上传图片',order: 27,view: 'image', type: 'string',},
};
